### The GIM root directory
GIMDIR = ../../..
## LNMLIB/src root directory
LNMDIR = ..
OPTS = 
CC=gcc
CXX=g++

CFLAGS=-Wall $(DEBUG) $(DEFINITIONS) $(CINCLUDES) $(CMISCFLAGS) $(LIBDIRS) $(OPTS) `xml2-config --cflags`
CPPFLAGS=-Wall  $(DEBUG) $(EXCEPTIONS) $(CPPINCLUDES) \
				$(DEFINITIONS) $(CPPMISCFLAGS) $(LIBDIRS) $(OPTS)
DEBUG=-O3 -g3
CMISCFLAGS=
CPPMISCFLAGS=
DEFINITIONS=-DLINUX_OS -D_GNU_SOURCE -DOS_LINUX -DT_GROUND_MODEL_MAP_DEBUG
EXCEPTIONS=-fexceptions

CINCLUDES=$(OCCU_INCLUDE) -I. $(INCGIMI)
CPPINCLUDES=$(OCCU_INCLUDE) -I$(GIMDIR)/glutImageGUI -I$(GIMDIR)/utils \
						-I$(GIMDIR)/ImageUtils/JPEGEncoder $(LNMINC) $(INCGIMI)
LIBDIRS=

LD=g++
LDFLAGS=$(LIBDIRS)

LIBS=-lrt -lpthread -lGL -lGLU -lglut -ljpeg $(LIBSGIMI)

CSRCUTIL = $(GIMDIR)/utils/ownutils.c $(GIMDIR)/utils/owndebug.c
CPPIMAGEGUI = $(GIMDIR)/glutImageGUI/glutImageGUI.cpp
CPPJPEG = $(GIMDIR)/ImageUtils/JPEGEncoder/JPEGEncoder.cpp

SRCSC=$(OCCU_SRC_C) $(CSRCUTIL)
SRCSCPP=$(OCCU_SRC_CPP) $(CPPIMAGEGUI) $(CPPJPEG)
VPATH=

include Makefile.occu
#include $(GIMDIR)/LnMlib/src/Makefile.lnmdata
#GDIR=$(GIMDIR)
#include $(GIMDIR)/GIMI/Makefile.gimi

## Construct final lists of CPP and C objects
OBJSC=$(SRCSC:.c=.o)
OBJSCPP=$(SRCSCPP:.cpp=.opp)

## Define compiles and links
COMPILEC=$(CC) $(CFLAGS) $(CINCLUDES) -c
COMPILECPP=$(CXX) $(CPPFLAGS) $(CPPINCLUDES) -c
LINK=$(LD) $(LDFLAGS)

.PHONY: all clean realclean
TARGETS = occutest occu_tool
all: $(TARGETS)
	
##witbin: $(OBJSC) $(OBJSCPP)

occutest: $(OBJSC) $(OBJSCPP) occutest.opp
			$(LINK) -o $@ $(OBJSC) $(OBJSCPP) occutest.opp $(LIBS)
			
occu_tool: $(OBJSC) $(OBJSCPP) occu_tool.opp
			$(LINK) -o $@ $(OBJSC) $(OBJSCPP) occu_tool.opp $(LIBS)

clean: 
	rm -f *.opp *.o $(TARGETS) *.out *~ *.d *.dpp

realclean:
	rm -f $(OBJSC) $(OBJSCPP) $(OBJ_LNM) $(OBJ_GSERVER_C) $(OBJ_GSERVER_CPP) $(OBJ_GCLIEN_C) $(OBJ_GCLIEN_CPP)\
 		grid hm gserver *.out *~ *.d *.dpp *.opp *.o

##manual:
##	doxygen

## Compile rule for all .o (.c) file
%.o:    %.c
				$(COMPILEC) -o $@ $<

## Compile rule for all .opp (.cpp) files
%.opp:	%.cpp
				$(COMPILECPP) -o $@ $<
